// 通用响应结构
export interface ApiResponse<T = any> {
  code: number
  message: string
  data: T
  success: boolean
}

// 分页参数
export interface PaginationParams {
  page: number
  size: number
  total?: number
}

// 分页响应
export interface PaginationResponse<T = any> {
  list: T[]
  total: number
  page: number
  size: number
  pages: number
}

// 排序参数
export interface SortParams {
  field: string
  order: 'asc' | 'desc'
}

// 搜索参数基类
export interface BaseSearchParams extends PaginationParams {
  keyword?: string
  sort?: SortParams
}

// 选项类型
export interface OptionItem {
  label: string
  value: any
  disabled?: boolean
  children?: OptionItem[]
}

// 树形数据结构
export interface TreeNode {
  id: string | number
  label: string
  children?: TreeNode[]
  disabled?: boolean
  [key: string]: any
}

// 文件上传响应
export interface UploadResponse {
  url: string
  name: string
  size: number
  type: string
  path: string
}

// 表格列配置
export interface TableColumnConfig {
  prop: string
  label: string
  width?: string | number
  minWidth?: string | number
  fixed?: boolean | 'left' | 'right'
  align?: 'left' | 'center' | 'right'
  sortable?: boolean | 'custom'
  showOverflowTooltip?: boolean
  formatter?: (row: any, column: any, cellValue: any, index: number) => string
}

// 表单验证规则
export interface FormRule {
  required?: boolean
  message?: string
  trigger?: 'blur' | 'change'
  min?: number
  max?: number
  len?: number
  pattern?: RegExp
  validator?: (rule: any, value: any, callback: any) => void
}

// 菜单权限
export interface Permission {
  id: string
  name: string
  code: string
  type: 'menu' | 'button' | 'api'
  path?: string
  method?: string
  description?: string
}

// 操作日志
export interface OperationLog {
  id: string
  userId: string
  username: string
  action: string
  module: string
  description: string
  ip: string
  userAgent: string
  createdAt: string
}

// 系统配置项
export interface ConfigItem {
  key: string
  value: any
  type: 'string' | 'number' | 'boolean' | 'json'
  description?: string
  group?: string
}

// 缓存信息
export interface CacheInfo {
  key: string
  value: any
  ttl: number
  size: number
  createdAt: string
  updatedAt: string
}

// 统计数据
export interface StatisticsData {
  label: string
  value: number
  unit?: string
  trend?: 'up' | 'down' | 'stable'
  percentage?: number
}

// 图表数据
export interface ChartData {
  labels: string[]
  datasets: Array<{
    label: string
    data: number[]
    backgroundColor?: string | string[]
    borderColor?: string | string[]
    borderWidth?: number
  }>
}

// 导出参数
export interface ExportParams {
  format: 'excel' | 'csv' | 'pdf'
  filename?: string
  fields?: string[]
  filters?: Record<string, any>
}

// 导入结果
export interface ImportResult {
  total: number
  success: number
  failed: number
  errors?: Array<{
    row: number
    message: string
  }>
}

// 批量操作参数
export interface BatchOperationParams {
  ids: (string | number)[]
  action: string
  params?: Record<string, any>
}

// 批量操作结果
export interface BatchOperationResult {
  total: number
  success: number
  failed: number
  errors?: Array<{
    id: string | number
    message: string
  }>
}